/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//		File Name		:		CGamePlayState.h
//
//		Author			:		Vindicated Games
//
//		Purpose			:		A header for all functions and members of the Game Play State
//
//		Dates			:		Written( Feb 12, 2011 ) by Vindicated Games		LastUpdate( Feb 17, 2011  ) by Vindicated Games 
//	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#ifndef GAMEPLAY_STATE_H_
#define GAMEPLAY_STATE_H_

#include "IBaseState.h"
#include "../Core/Ilistener.h"
#include "../Core/CJCEvent.h"
#include <vector>
#include "../Animation/CAnimation.h"
using std::vector;

//#include "../Game Objects/CPlayer.h"
//#include "../Game Objects/Cenemy.h"
//#include "../Game Objects/CEmitter.h"
//#include "../Core/CPlayerProfile.h"
//#include "../Game Objects/CBaseObject.h"

class CPlayerProfile;
class CBaseObject;
class CMeleeEnemy;
class CBaseEnemy;
class CEmitter;
class CPlayer;
class CMasterHand;
class CButton;

struct WaveInfo
{
	float fWaveTime;
	int NumOfEnemies;
};


class CGamePlayState : public IBaseState, public IListener
{

private:

	CGamePlayState();
	~CGamePlayState();
	CGamePlayState(const CGamePlayState& copy);
	CGamePlayState& operator=(const CGamePlayState& assign);

	bool IsInGame;
	bool start;

	CMasterHand* masterHand;
	CPlayer* pPlayer;
	CBaseObject* pLight;
	CEmitter* pEmitter;
	CBaseEnemy* pEnemy;

	vector<CAnimation> vAnimation;
	
	//////////////////////////////////////////////////

	CMeleeEnemy* enemy_ME;
	vector<WaveInfo> m_vWaves;
	CJCEvent m_JCE;

	//////////////////////////////////////////////////

	CPlayerProfile* ActiveProfile;

	//Level control point
	IBaseState* pLevelState;

	int PlayerImage;
	int HUDButtonID;
	int castleID;
	int PauseID;
	int ImageID;
	int HUDID;

	/////////////////////////////////////////////////////


	int m_nNumOfEnemies;
	int m_nMaxEnemies;
	int m_nNumOfDeadEnemies;
	int m_nPrevCount;
	int WaveCount;
	int RoundCount;
	float m_fWaveTime;
	bool m_bNoTimeUpdate;
	float fEnemySpawnBucket;
	bool m_bRoundComplete;

	int m_nRoundCount;
	bool m_bWaveOver;
	float m_fEndOfWaveBucket;

	int background;
	int castle;
	int back;

	CMeleeEnemy* TemplateEnemy;	
	void ResetRound();
	/////////////////////////////////////////////////////

	int m_nPauseSelection;
	bool SaveBeforeExit;
	bool m_bWinGame, m_bGameOver, m_bTriggedEvent, m_bGamePaused;

	float fBucketTE;
	int score;


protected:


public:
	//Singleton Accessor
	static CGamePlayState* GetInstance();

	//Neccessary Class member functions to Instnatiate
	void Enter();
	bool Input();
	void Update(float fElapsedTime);
	void Render();
	void Exit();

	bool Load( const char* AnimInfo);
	void UpdatePlayerProfile();

	bool GetGameStatus()	{return IsInGame;}

	CMasterHand* GetHand() { return masterHand; }
	CPlayer* GetPlayer()	{ return pPlayer; }
	bool GetTrigger()		{ return m_bTriggedEvent; }
	void SetTrigger( bool newTriggerStatus )		{ m_bTriggedEvent = newTriggerStatus; }
	IBaseState* GetLevel()	{	return pLevelState; }

	void WinGame(bool yah){m_bWinGame = yah;}
	void GameOver(bool yah){m_bGameOver = yah;}
	bool GetWin() {return m_bWinGame;}
	bool GetLose(){return m_bGameOver;}
	bool GetPause()	{return m_bGamePaused;}
	void SetPause(bool yah)	{	m_bGamePaused = yah; }

	void HandleEvent(CEvent* pEvent);
	bool GetTrigEvent()		{return m_bTriggedEvent;}
	
	int CalculateScore();
	void RenderHUD();

	/////////////////////////////////////////////////////

	int GetDeadEnemies()		{ return m_nNumOfDeadEnemies; }
	int GetMaxEnemies()			{ return m_nMaxEnemies; }
	int GetNumOfDeadEnemies()	{ return m_nNumOfDeadEnemies; }
	int GetWaveCount()			{ return WaveCount; }
	float GetWaveTime()			{ return m_fWaveTime;}
	int GetRoundCount()			{ return m_nRoundCount; }

	void SetDeadEnemies( int newEnemyCount )	{ m_nNumOfDeadEnemies = newEnemyCount;	}
	void SetMaxEnemies( int newMaxEnemies	)	{ m_nMaxEnemies = newMaxEnemies; }
	void SetRoundComplete()		{m_bRoundComplete = !m_bRoundComplete; }
	void IncrementDead()	{m_nNumOfDeadEnemies++;}
	void SpawnEnemies();
	void WaveSet();
	void InitWaves();
};
#endif